import { Modal,Message  } from "@garco-design/web-vue";
/**
 * 删除弹窗
 * @param {object} record 当前行数据
 * @param {function} callback 删除成功回调
 * @param {function} refreshData 刷新数据
 * @param {Array} ids 删除【】数据
 * @param {string} content 删除提示内容
 * @param {string} title 弹窗标题
 */
export const warningModal = (content,callback,title = '提示') => {
  Modal.confirm({
    title,
    content,
    onOk: () => {
      callback()
    }
  })
};
export const deleteModalWithRefresh = (
  record,
  callback,
  refreshData,
  ids=[],
  content,
  title = "提示",
) => {
  Modal.confirm({
    title,
    content: content ||  `确定要删除-[${record?.name}]` ,
    onOk: async () => {
      try {
        const { code } = await callback(record?.id,ids);
        if (code === 20000) Message.success("操作成功");
        refreshData()
      } catch (err) {
        console.log(err);
      }
    },
  });
};